package com.zy.ddd.demo.business.borrow.domain.aggregate;

import com.zy.ddd.demo.business.borrow.domain.valobj.BookInfoVo;

import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;

import lombok.Data;

/**
 * 借书单
 * @author hugx
 * @create 2020-02-03 18:42
 */
@Data
public class CallSlipAgg {
    private LocalDate borrowDate ; //借书日期
    private Set<BookInfoVo> bookInfoVos;//图书信息

    /**
     * 添加图书信息
     * @param bookInfoVo
     */
    public void addBookInfoVo(BookInfoVo bookInfoVo){
        if(bookInfoVo == null){
            return;
        }

        if(bookInfoVos == null){
            bookInfoVos = new HashSet<>(1);
        }
        bookInfoVos.add(bookInfoVo);
    }

    /**
     * 删除图书信息集合中的图书信息对象
     * @param bookInfoVo
     */
    public void removeBookInfoVo(BookInfoVo bookInfoVo){
        if(bookInfoVo == null || bookInfoVos.isEmpty()){
            return ;
        }

       bookInfoVos.remove(bookInfoVo);
    }


}
